package com.tidc.deleteprovider.deleteController;


import com.tidc.deleteprovider.ov.UserOV;
import com.tidc.deleteprovider.service.DeleteService;
import com.tidc.deleteprovider.utiles.ApplicationContextProvider;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.javassist.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassNmae StudentDeletController
 * @Description TODO
 * @Author 14631
 **/
@CrossOrigin(origins = "*",maxAge = 3600)
@RequestMapping("/student")
@RestController
public class StudentDeletController {
	@Autowired
	private ApplicationContextProvider ac;
	@Autowired
	private DeleteService deleteService;

	@ApiOperation(value = "学生删除自己创建的项目 需要要删除的项目的id")
	@DeleteMapping("/delete/work/{id}")
	public UserOV deleteWork(@PathVariable(value = "id")int id, String token) throws NotFoundException {
		UserOV userOV = ac.getBean(UserOV.class);
		return deleteService.deleterWork(id,userOV,token);
	}
	@ApiOperation("学生删除自己项目的队员")
	@DeleteMapping("delete/member/{teamid}/{studentid}")
	public UserOV deleteMember(@PathVariable(value = "teamid")int teamId, String token, @PathVariable(value = "studentid")int stduentId){
		UserOV userOV = ac.getBean(UserOV.class);
		return deleteService.deleteMember(teamId, stduentId, userOV, token);
	}
}
